import router from '@/router';
import settings from '@/settings';
export default {
  methods: {
    getSlotRsr() {
      sa.ajax('/rsr/apply/getSlotRsr', function (res) {
        if (res.code === 200) {
          this.dataList = res.data
        } else {
          // 处理错误情况
          sa.msg('获取资源投放记录失败，请稍后重试！')
        }
      }.bind(this), {
        type: "post"
      })
    },

    //投放广告
    slotAds() {
      if (sa.$sys.getToken()) {
        sa.showModel('投放广告', () => import('@/views/scs/apply/ads'), {
          item: {
            resourceId: this.dims.ADS_LOCATION_CODE_ID[this.spaceCode]
          }
        });
      } else {
        sa.confirm('当前未登录，是否跳转至登录页面···', function () {
          //跳转到登录
          router.replace({
            path: settings.scs_url
          })
        });
      }
    },

    //投放资源
    slotRsr() {
      if (!sa.$sys.getToken()) {
        sa.msg('请先登录后,再投放资源!')
        return;
      }
      sa.showModel('投放资源', () => import('@/views/scs/apply/rsr'), {
        item: {}
      });
    },

    // 点击
    clickRsr(id) {
      sa.ajax('/rsr/click-on', {
        id: id
      }, function (_res) {
        // 缓存 资源id
        sa.$sys.setSrId(id)
        this.$router.push({ path: settings.show_url });
      }.bind(this), {
        type: 'get'
      });
    },
  }
}